<template>
  <div>
    <div class="content">
      <div class="my-header">
        <!--<div class="my-settings">
          <i class="iconfont icon-message"></i>
        </div>-->
        <div class="userinfo">
          <div class="avatar">
            <img v-if="!userInfo" src='~assets/common/images/none-bg.jpg' alt="">
            <img v-else :src="userInfo.userImg" alt="">
          </div>
          <div class="info-box">
            <div v-if="!userInfo" @click.stop.prevent="$router.push({name:'login',query:{redirect:'/home'}})">
              <span class="username">登录/注册</span>
            </div>
            <div v-else  @click="$router.push('/setting')">
              <span class="username">{{userInfo.userName}}</span><i class="iconfont icon-right"></i>
            </div>
            <div class="my-account-info" v-if="accountInfo">
              <span class="user-type">{{ accountInfo.userType===2?'企业用户':'个人'}}</span>
              <!--<span class="user-status" v-if="accountInfo.authStatus===0">开通企业认证</span>
              <span class="user-status" v-else-if="accountInfo.authStatus===1">企业认证审核中</span>
              <span class="user-status" v-else-if="accountInfo.authStatus===3">企业认证拒绝</span>
              <span class="user-status" v-else>企业账户</span>-->
            </div>
          </div>
          <!--<div class="iconfont icon-right">
          </div>-->
        </div>
      </div>
      <div class="my-order">
        <div class="order-item" @click.stop.prevent="!handlerEvent ? $router.push('/orderList/1'):false">
          <img src="~assets/common/images/paymenticon.png" alt="">
          <span>待付款</span>
        </div>
        <div class="order-item" @click.stop.prevent="!handlerEvent ? $router.push('/orderList/2'):false">
          <img src="~assets/common/images/received.png" alt="">
          <span>待收货</span>
        </div>
        <div class="order-item" @click.stop.prevent="!handlerEvent ? $router.push('/orderList/0'):false">
          <img src="~assets/common/images/evaluated.png" alt="">
          <span>待评价</span>
        </div>
        <div class="order-item">
          <img src="~assets/common/images/Aftermarket.png" alt="">
          <span>退换退款</span>
        </div>
        <div class="order-item myorder" @click.stop.prevent="!handlerEvent ? $router.push('/orderList/0'):false">
          <img src="~assets/common/images/myordericon.png" alt="">
          <span>订单</span>
        </div>
      </div>
      <div class="cell-container">
        <div class="cell-list">
          <div class="cell-item" @click="$router.push(`/collection`)">
            <div class="left">
              <i class="iconfont icon-right"></i> <span>商品收藏</span>
            </div>
            <div class="right">
              <i class="iconfont icon-right"></i>
            </div>
          </div>
          <!--<div class="cell-item" @click="$router.push(`/`)">
            <div class="left">
              <i class="iconfont icon-right"></i><span>会员等级</span>
            </div>
            <div class="right">
              <i class="iconfont icon-right"></i>
            </div>
          </div>-->
          <div class="cell-item" @click="$router.push(`/wallet`)">
            <div class="left">
              <i class="iconfont icon-right"></i> <span>余额</span>
            </div>
            <div class="right">
              <i class="iconfont icon-right"></i>
            </div>
          </div>
          <div class="cell-item" @click="$router.push(`/addressList`)">
            <div class="left">
              <i class="iconfont icon-right"></i> <span>地址</span>
            </div>
            <div class="right">
              <i class="iconfont icon-right"></i>
            </div>
          </div>
          <div class="cell-item" @click="$router.push(`/applyInvoice`)">
            <div class="left">
              <i class="iconfont icon-right"></i> <span>发票</span>
            </div>
            <div class="right">
              <i class="iconfont icon-right"></i>
            </div>
          </div>
          <div class="cell-item" @click="$router.push(`/security`)">
            <div class="left">
              <i class="iconfont icon-right"></i> <span>账户安全</span>
            </div>
            <div class="right">
              <i class="iconfont icon-right"></i>
            </div>
          </div>
        </div>
      </div>
    </div>
    <footertab></footertab>
  </div>
</template>
<script>
  import {
    mapGetters
  } from 'vuex'
  import footertab from '@/components/footer/footer'
  export default {
    data() {
      return {
        // accountInfo: {

        // },
        handlerEvent: false,
        statusText: ''
      }
    },
    computed: {
      ...mapGetters([
        'userInfo',
        'accountInfo'
      ])
    },
    watch: {},
    components: {
      footertab
    },
    methods: {
      fetchData() {
        // 判断是否登录
        this.isLogin = this.userInfo ? 1 : 0
        if (!this.userInfo) return
        const params = {
          userId: this.userInfo.id
        }
        // 获取用户详细信息
        if (!this.accountInfo) {
          this.$store.dispatch('GetAccountInfo', params).catch(() => {})
        }
        // getAccountInfo(params).then(res => {
        //   this.accountInfo = res.data.userInfo
        // }).catch(() => {})
      }
    },
    created() {
      this.fetchData()
    }
  }

</script>
<!-- myhome -->
<style lang="scss" scoped>
  @import '~assets/common/css/mixin.scss';
  .content {
    padding-bottom: 1.35rem;
    min-height: 100vh;
  }

  .my-header {
    height: 3.5rem;
    padding: 10px 15px;
    background: -webkit-linear-gradient(left, #F5A623, #ff6700);
    background: linear-gradient(90deg, #F5A623, #ff6700);
    box-shadow: 0 2px 5px rgba(255, 98, 98, .4);
    position: relative;
    &:after {
      content: '';
      position: absolute;
      bottom: -0.54rem;
      left: 0px;
      width: 100%;
      background: -webkit-linear-gradient(left, #F5A623, #ff6700);
      background: linear-gradient(90deg, #F5A623, #ff6700);
      height: 1rem;
      border-radius: 50%;
    }
    @include flexbox(flex-start, space-between, column, wrap);
    .my-settings {
      position: absolute;
      right: 10px;
      .icon-message {
        display: block;
        color: #fff;
        font-size: 24px;
      }
    }
    .userinfo {
      position: relative;
      width:100%;
      padding-top: 1rem;
      @include flexbox(flex-start,
      center,
      row,
      nowrap);
      .avatar {
        img {
          border: 1px solid hsla(0, 0%, 100%, .4);
          border-radius: 60px;
          box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
          width: 60px;
          height: 60px;
        }
      }
      .info-box {
        width: 100%;
        @include flexbox(center,
        flex-start,
        column,
        wrap);
        flex: initial;
        padding: 0 15px;
        color: #fff;
        font-size: 16px;
        .my-account-info {
          .user-type {
            position: relative;
            display: inline-block;
            vertical-align: middle;
            padding: 3px 10px;
            font-size: 10px;
            color: #fff;
            border-radius: 12px;
            background: #9f3838;
            border: 1px solid #9f3838;
          }
        }

        .username {
          margin: 5px 0;
        }
      }
      .icon-right {
        position: absolute;
        color: #fff;
        right: 10px;
      }
    }
  }

  .my-order {
    clear: both;
    background: #fff;
    padding: 40px 0 20px;
    @include flexbox(center,
    center,
    row,
    nowrap);
    .order-item {
      width: 20%;
      @include flexbox(space-between,
      center,
      column,
      wrap);
      img {
        height: 35px;
      }
      span {
        margin: 10px 0 0;
        font-size: 13px;
        color: #333;
      }
      &.myorder {
        position: relative;
        border-left: 1px solid #eee;
        &:before {
          content: '';
          position: absolute;
          left: -2px;
          z-index: 999;
          top: calc(100%/2 - 10px);
          width: 0;
          height: 0;
          border: 8px solid transparent;
          border-left-color: #fff;
        }
        &:after {
          content: '';
          position: absolute;
          left: 0;
          top: calc(100%/2 - 10px);
          width: 0;
          height: 0;
          border: 8px solid transparent;
          border-left-color: #eee;
        }
      }
    }
  }

  .cell-container {
    background: #fff;
    margin-top: $margin;
    .cell-list {
      .cell-item {
        @include flexbox(space-between,
        center,
        row,
        nowrap);
        border-bottom: 1px solid #eee;
        margin-left: $padding;
        padding: $padding $padding $padding 0;
        .left {
          span {
            font-size: $subtitle;
            color: #333;
          }
        }
        .right {
          .icon-right {
            font-size: 13px;
            color: #ADADAD;
          }
        }
        &:last-child {
          margin-left: 0;
          padding-left: $padding;
        }
      }
    }
  }

  .my-attention {
    clear: both;
    background: #fff;
    margin-top: 10px;
    padding: 10px 0;
    @include flexbox(center,
    center,
    row,
    nowrap);
    .attention-item {
      width: 25%;
      @include flexbox(space-between,
      center,
      column,
      wrap);
      strong {
        text-align: center;
        font-size: 16px;
        font-weight: normal;
        background-image: -webkit-linear-gradient(left, rgb(255, 42, 0), rgb(255, 0, 175));
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }
      span {
        margin: 10px 0;
        font-size: 14px;
        color: #333;
        text-align: center;
      }
    }
  }
  /* 为您推荐 */

  .my-recommend {
    clear: both;
    margin-top: 10px;
    .recommend-tip {
      text-align: center;
      margin: 0 0 10px;
      img {
        height: 35px;
      }
    }
    .recommend-list {
      background: #fff;
      @include flexbox(flex-start,
      center,
      row,
      wrap);
      overflow: hidden;
      clear: both;
      .recommend-item {
        background: #fff;
        width: 4.935rem;
        margin-bottom: .15rem;
        .item-posre {
          img {
            max-height: 185px;
            width: 100%;
          }
        }
        .item-product-text {
          padding: .1rem 0 0 .1rem;
          font-size: 14px;
          @include textoverflow(2);
        }
        .item-product-info {
          color: #f23030;
          padding: .2rem .1rem;
          font-size: 16px;
          span {
            font-size: 12px;
            margin-right: .1rem;
          }
        }
        .item-product-praise {
          padding: 0 0 .2rem .1rem;
          font-size: 12px;
          color: #999;
        }
      }
    }
  }
  /* 为您推荐 */

</style>
